Previous Book Next
XFaceMaker White Paper



5 Interface Behavior

As we have seen, the XFaceMaker/EL and XFaceMaker products allow the specification of interface behavior in scripts written in the FACE language. Several features of the implementation of behavior scripts in XFaceMaker are noteworthy and superior to competing tools:

FACE

The FACE language has been designed to meet the following objectives:

FACE is very close to C and can be learned by any C programmer in about one hour. We have added syntactic constructs that allows a more convenient and compact reference to widgets and their resources than the clumsier function calls needed in C.

The main features of the FACE language are:

Control structures and operators

FACE supports most control structures and operators of C.

Variables

FACE supports variables, which can be local to a script or global, i.e., usable in all scripts. You need not declare variables in FACE as their type is determined by use. If you assign an integer to a variable it will have integer type. Most C types are supported.

Structures and arrays

FACE supports two types of arrays: hashed and linear. Hashed arrays can be indexed by string keys or by an arbitrary one-word key. Linear arrays are similar to C arrays.

FACE also supports structures similar to C structures, except that only access to structure pointers is provided.

Built-in functions

FACE comes with a very rich set of basic built-in functions which can be called at will in scripts. The basic set includes some C, most X Intrinsics and all Motif functions, in addition to numerous convenience functions that have been added to make writing scripts even easier. The set of built-in functions can also be increased. One can link into XFaceMaker any number of libraries or user functions that can be called from scripts to obtain an extended version of the tool.

Function definition

FACE supports function definition, including recursive definitions.

In addition to functions defined in scripts, there are application functions declarations which make application functions known to the FACE interpreter.

Widget naming scheme, widget resource and X properties reference

One of the most useful features in FACE is its widget naming scheme. You can refer to a widget by its name, which is essentially its path in the widget tree.

You can append the name of a resource to a name and refer to the resource in this way.

The equivalent C code that you would have to write if you used an IDT or a UIMS that had C as a scripting language, is considerably longer, because of the use of unwieldy Xlib, Xt or Motif function calls.

Active values - a unique and powerful mechanism for sharing variables with

the application

FACE introduces a unique and original mechanism for sharing data and signals between the interface scripts and the application - active values. The X window system provides only callbacks for this communication, but in many cases callbacks are not the most natural method for transferring data or signals between the interface and the application, and the active values mechanism has been designed to fill this gap.

It is best to think of an active value as the association of an application variable, an interface resource and two FACE scripts - the Set and the Get script. The Set scripts will transform the application variable into the resource and the Get script will do the converse. The two scripts can be triggered from the application or from other scripts.

As a simple example, an active value could associate an integer application variable v and a label in the GUI. The Set script would then transform v into the label by applying the itoa conversion function available in the FACE library. The Get script would do the converse using the atoi function.

There is complete flexibility in the way variables, widgets and active values are associated. It is possible to associate several active values to the same widget. Or, one could have the same active value associated with several widgets. In this case the Set script of the active value can be triggered simultaneously for all the widgets, broadcasting the same information to all the widgets. Alternatively, it could be triggered for some widgets only. Active values can even be used to add resources to a widget without having to build a whole new class. The latter is particularly useful when building new widgets with the Widget Factory.

An active value can be global or specific to a widget, it can be public or private and can be automatic or immediate. An automatic and per-object active value can be given an initial value, which will be assigned to it just after the object to which it is associated is created. Automatic, per object active values appear in the resource list and resource editors of XFaceMaker.

Active values are quite frequently used to transmit an interface widget ID to the application or to another script. This avoids having to refer to widgets by name and makes scripts insensitive to name changes.

Active values can also be used to send signals from the application to the interface, for the synchronization of data displaying different widgets and for adding new resources to widgets defined with the Xt class generation capability of XFaceMaker.

The FACE Debugger

The FACE interpreter also has a powerful debugger. With the FACE debugger, it is possible to:

Customizing XFaceMaker - linking with libraries and the application

FACE scripts can call any function. If the function is known to XFaceMaker it will be executed, otherwise a warning message will be issued, although the script will be executed to the end. In the version released with the product, FACE knows some of the Xlib and Xt (Intrinsics) functions and all of the Motif functions.

It is also possible to link XFaceMaker with any set of libraries, for example other graphic libraries, mathematical libraries or data base handling libraries. When you do this, you can call any of these functions from your scripts.

This procedure applies in particular to the core of your application. From XFaceMaker's point of view, the core of the application consists of a collection of C functions. If XFaceMaker is linked with the application in this way, any function of the application can be called from a script and tested in try mode.

Editing the interface from a running application

A uniquely powerful feature of the XFaceMaker/EL and XFaceMaker products is the possibility of linking the tool with the application proper.

The application can then be run and the editor called at any time so that the interface can be edited with the application running.

This feature is especially useful, for example, in the case of interfaces sensitive to timing constraints, where it is essential to test the interface and application simultaneously and make adjustments to the interface.

Previous Book Next